
import { StyleValue } from "vue";
import type { LowCodeConf, LowcodeGridRowColComponents, LowCodeInfo, LowcodeMdInfo, LowcodeMenuCFG, LowcodeMenuItemCFG, LowcodePage, LowcodePagePanel, LowcodePagePanelComponentItem, LowcodeRect } from "../interface";
import type { LowcodeTableSaveData } from "../hooks/interface";

export interface FetchMdBillRichDetailProxy {
  isOnLoad?: boolean;
}

export interface validateRichErrorItem { oldVal: any; newVal: any; msg: string };

export interface MdBillRichDetailProps {
  billId?: string;
  LowcodeGuid: string;
  LowcodeDetailGuid: string;
  parentType?: string; // approveManger 待审批打开的本页面
  mdInfo?: string;
};

export interface MdRichDetailBasicState {
  systemInfo?:  { [key: string]: any };
  lowcodeInfo?: LowCodeInfo;
  menusCFG?: LowcodeMenuItemCFG[];
  menusCFGMore?: any[];
  navWrapRect?: LowcodeRect;
  createPopupStyle?: StyleValue;
  cIdConf?: LowcodePagePanelComponentItem;
  enableApprove?: boolean;
  mdInfo?: LowcodeMdInfo;
  c_menuCFG?: LowcodeMenuItemCFG[];
  mainCardStyle?: StyleValue;
  
  // 数据
  mainFormData?: { [key: string]: any };
  otherPanelData?: { [key: string]: any };
  // 主表
  mainFormPanel?: LowcodePagePanel; // 接口返回的初始区块
  mainFormPanelGrid?: LowcodeGridRowColComponents; //  带有栅格信息，用于显示的区块
  mainCellProps?: { [key: string]: any };    // CellProps 对应组件的属性信息
  // 从表
  otherPanelObj?: { [key: string]: LowcodePagePanel };
  otherPanelGridObj?: { [key: string]: LowcodeGridRowColComponents };
  otherCellProps?: { [key: string]: any };
  enableRowDelete?: boolean;
  //子卡片
  subPanelsEditFields?: { [key: string]: { [key: string]: LowcodePagePanelComponentItem } };
  subPanelsGridObj?: { [key: string]: LowcodeGridRowColComponents[] };
  subCellProps?: { [key: string]: any };
};

export interface MdBillRichDetailState extends MdRichDetailBasicState {
  // mainFormPanel?: LowcodeGridRowColComponents;
  approveStyle?: StyleValue;
  otherCellPropsAny: { [key: string]: boolean }; // 是否需要显示 从表卡片
};

export interface MdEditRichDetailState extends MdRichDetailBasicState {
  editWrapStyle?: StyleValue;
  popupData?: { [key:string]: any };
  pageTitle?: string;
  editTbIdx?: number;
  editPanelGuid?: string;
  editTbRowData?: { [key:string]: any };
  validateErrorDataPage?: { [key:string]: validateRichErrorItem };
  validateErrorDataPop?: { [key:string]: validateRichErrorItem };
  billIdAfterSave?: string;

  initMainFormData?: { [key:string]: any };
  initOtherPanelData?: { [key: string]: any };
  initOtherPanelDataObj?: { [key: string]: { [key:string]: any } };

  tableSaveData?: { [key:string]: LowcodeTableSaveData };
  
  mainComponentConf?: { [key: string]: LowcodePagePanelComponentItem };
  otherComponentConf?: { [key: string]: { [key: string]: LowcodePagePanelComponentItem } };

  mainCardTitle?: string;
  otherCardTitle?: { [key:string]: string };
}

export interface BillRichDetailFetchRes extends LowCodeConf {};

export interface BillRichDetailFetchReq {
  LowcodeGuid: string;
  LowcodeDetailGuid: string;
};

export interface FetchRichDetailDataReq {
  BillId?: string;
}

export interface FetchRichDetailDataRes {
  [key: string]: any[]
}
